package com.tuanzi.loan.web.bean.family;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.service.family.CommSysCodeService;
import com.tuanzi.loan.business.service.family.ProductInfoService;
import com.tuanzi.loan.business.service.system.DictionaryService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.family.SpaceConfInfoSearchRequest;
import com.tuanzi.loan.vo.response.family.SpaceConfInfoSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingSessionBean;
import com.tuanzi.loan.web.lazy.family.SpaceConfInfoLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.faces.bean.ViewScoped;
import java.util.List;

import static com.tuanzi.loan.business.constants.DictionaryCode.ONLINE_OFFLINE_STATUS;

/**
 * @author weibifeng 2017/09/21
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class SpaceConfListBean extends JSFListingSessionBean<SpaceConfInfoSearchRequest, SpaceConfInfoSearchResponse> {

	private static final long serialVersionUID = -2152778554108785342L;
	@Autowired
	private ProductInfoService productInfoService;
	@Autowired
	private DictionaryService dictionaryService;
	@Autowired
	private CommSysCodeService commSysCodeService;

	public void onReset() {
		initLazyDataModel();
	}

	public String onAdd() {
		return redirect("/views/family/tags/space-conf/info.xhtml");
	}

	public String onEdit(String id) {
		return redirect("/views/family/tags/space-conf/info.xhtml?id=" + id);
	}

	@Override
	protected String page() {
		return "/views/family/tags/first-party/list.xhtml";
	}

	@Override
	protected void initLazyDataModel() {
		$ = new SpaceConfInfoSearchRequest();
		lazyDataModel = new SpaceConfInfoLazyDataModel($, session, commSysCodeService);
	}

	@Override
	protected List<String> getDictionaryCodes() {
		return Lists.newArrayList(ONLINE_OFFLINE_STATUS);
	}

}
